Determining the version of Video for Windows and QuickTime in Director
You can use the Lingo command "MCI" (Media Control Interface) to send strings from within Director to the MCI drivers that are loaded in Windows. The MCI driver will in turn control the actual devices or files that you are trying to control, such as a laser disc players, digital video files, MIDI sound files, or other such external elements.
The following handler tells Director to pass MCI calls to the MCI digital video drivers. The MCI command finds out the version of QuickTime or Video for Windows. In addition, the handler sends an MCI string to actually play a digital video movie, which is located in the same directory as the Director movie.
Director for Windows:
on exitFrame
MCI "open AVIVIDEO alias filename.avi"
MCI "info filename.avi version"
put the result into field "Display"
MCI "play filename.avi"
go to the frame
end
To find out the QuickTime version, simply substitute QTWVIDEO for AVIVIDEO, and filename.mov for filename.avi. In order to get this information on the Macintosh, you need the QTVersion XFCN.
The "MCI" Lingo command sends strings to the MCI drivers loaded in Windows. By typing MCI "sample mci string" in a Lingo handler, Director tells MCI to execute the command in quotes, i.e. MCI "Play CDAUDIO".
Note: Be sure that you use the close command to close the device after the movie is finished playing. If you close the device right after you issue the play command without delay, the movie will only play for a short time, and you will see the movie "flash".
Determining the version of Video for Windows or QuickTime in Authorware
Load the MCISendString and MCIReturnString functions from A3WMME.UCD on your Authorware 3.0 CD-ROM. The files are located in the directory, "Goodies\UCD". For directions on how to load a function, see "Loading Functions" on page 540 of "Using Authorware".
In order to determine the version of QuickTime or Video for Windows, set up a new file and perform the following steps. Drag a calculation icon to the flowline. Type the following lines into the calculation icon. (Be sure to realize that sharks.avi is only a sample name; you should put in the name and pathname of a digital video file that you actually have on your disk.) The alias "movie" is simply a new, easier-to-use name, that represents a link to your path and filename.
MCISendString("open sharks.avi type AVIVIDEO alias movie")
MCISendString("play movie")
MCISendString("info movie version")
result :=MCIReturnString()
Finally, you need to drag a display icon to the flowline. Open up the icon. Type {result} with the text tool. This will display the variable "result", which now contains the version number of Video for Windows. Remember, if you need the QuickTime version, simply substitute QTVIDEO for AVIVIDEO in the above calculation.
Note: Be sure that you use the close command to close the device after the movie is finished playing. If you close the device right after you issue the play command without delay, the movie will only play for a short time, and you will see the movie "flash".
Playing digital video movies with MCI in Authorware for Windows:
For details on how to run your digital video through MCI, note the following resources:
òPage 73 of "Authorware Tips and Tricks" which
ships with Authorware for Windows.
òTechNote #3013, "Playing Digital Video Devices
with MCI in APW"
òTechNote #3028, "ReelMagic MPEG Playback in Authorware."
Two books for MCI are the "Microsoft Multimedia Programmers' Reference" in various editions from Microsoft Press, and "Windows Multimedia 3.1" by Roger Jennings [Que, 1992]. Both describe a wide range of Media Control Interface commands.
It's important to note, though, that various MCI devices will respond to various commands in various ways. MCI provides an interface between applications and media devices, but does not mandate how they will interact.
Another useful resource while developing with MCI is CompuServe. The Multimedia, WinMedia, and various Microsoft forums are gathering places for many people with strong MCI experience. Lurking or posting messages there is the fastest way to gain MCI expertise. Microsoft's Web URL on the Internet is:
http://www.microsoft.com.
MCI Reference
This section is included for a quick reference. These commands only scratch the surface of Windows Multimedia Extensions. You should consult the above-mentioned books for complete programming reference.
The Media Control Interface (MCI) is a high-level command interface to multimedia devices and resource files. MCI provides applications with device-independent capabilities for controlling audio and visual peripherals. Your application can use MCI to control any supported multimedia device, including audio playback and recording. For a full overview of MCI, see the Multimedia Programmer's Guide.
MCI provides standard commands for playing multimedia devices and recording multimedia resource files. Using MCI, an application can control multimedia devices using simple commands like open, play, and close. MCI commands are a generic interface to multimedia devices.
MCI includes the following interfaces:
The command-message interface consists of C constants and structures. The Multimedia Programmer's Guide describes the command-message interface and presents numerous examples on using the command messages to control audio devices. In the Multimedia Programmer's Reference, the individual command messages and structures are described in Chapter 4, "Message Overview", Chapter 5, "Message Directory", and Chapter 6, "Data Types and Structures."
The command-string interface provides a textual version of the command messages. The strings use an easy-to-read format that makes it easy to control MCI devices from C programs and multimedia authoring tools. Command strings duplicate the functionality of the command messages; Windows converts the command strings to command messages before sending them to the MCI driver for processing.
Controlling MCI Devices
To control an MCI device, you open the device, send the necessary commands to it, and then close the device. For example, the following series of MCI commands play rack 6 of an audio CD:
"open cdaudio"
"set cdaudio time format tmsf"
"play cdaudio from 6 to 7"
"close cdaudio"
The next example shows a similar series of MCI commands that play the first 10,000 samples of a waveform audio file:
"open c:\mmdata\purplefi.wav type waveaudio alias finch"
"set finch time format samples"
"play finch from 1 to 10000"
"close finch"
You will note the following from the previous examples:
The same basic commands (open, play, and close) are used with both devices. The open command for the "waveaudio" device includes a filename specification. The "waveaudio" device is a compound device (one associated with a media element), while the "cdaudio" device is a simple device (one without an associated media element).
The set commands both specify time formats, but the time-format options for the "cdaudio" device differ from those used with the "waveaudio" device.
The parameters used with the from and to flags are appropriate to the respective device. For the "cdaudio" device, the parameters specify a range of tracks; for the "waveaudio" device, the parameters specify a range of samples.
MCI Device Types and Drivers
MCI recognizes a basic set of device types. A device type is a set of MCI drivers that share a common command set and are used to control similar multimedia devices or data files. The following table lists the currently defined device types. The current implementation of MCI includes command sets for a subset of these devices.
Device Type Description
----------- --------------------------
animation Animation device
cdaudio Audio CD player
dat Digital audio tape player
digitalvideo Digital video in a window (not GDI based)
other Undefined MCI device
overlay Overlay device (analog video in a window)
scanner Image scanner
sequencer MIDI sequencer
vcr Videotape recorder or player
videodisc Videodisc player
waveaudio Audio device that plays digitized waveform files
MCI Device Names
For any given device type, there might be several MCI drivers that share the command set but operate on different data formats. For example, the animation device type might include several MCI drivers that use the same command set but play different types of animation files. To uniquely identify a MCI driver, MCI uses device names. Device names are identified in the [mci] section of the SYSTEM.INI file. The [mci] section of SYSTEM.INI identifies all MCI drivers to Windows. The following example shows a typical [mci] section:
[mci]
waveaudio=mciwave.drv
sequencer=mciseq.drv
avivideo=mciavi.drv
cdaudio=mcicda.drv
The name on the left side of the equal sign is the driver device name. The value on the right side of the equal sign identifies the filename of the MCI driver. Frequently, the device name is the same as the device type for the driver, as is the case for the waveaudio, sequencer, and cdaudio devices in the preceding example. If an MCI driver is installed using a device name that already exists in the [mci] section, Windows appends an integer to the device name of the new driver, creating a unique device name. In the preceding example, a driver installed using the cdaudio device name would be assigned device name "cdaudio1." A subsequent cdaudio device would be assigned device name "cdaudio2."
MCI Drivers Included with Windows
The retail Windows package includes the following MCI drivers:
Device Name Driver Filename Description
-----------------------------------------
sequencer MCISEQ.DRV An MCI device driver for playing MIDI
audio files.
waveaudio MCIWAVE.DRV An MCI device driver for playing and recording
waveform audio files.
The Windows setup program creates an [mci] section in SYSTEM.INI that lists the sequencer and waveaudio devices. The device names are the same as the device type names.
The Windows SDK includes the following additional MCI drivers:
Device Name Driver Filename Description
-----------------------------------------
cdaudio MCICDA.DRV An MCI device driver for controlling
compact disc audio.
videodisc MCIPIONR.DRVAn MCI device driver for controlling
the Pioneer LD-V4200 videodisc player.
To install these devices, use the Drivers setting in Control Panel. You can distribute the MCICDA.DRV and MCIPIONR.DRV drivers with any applications that require them. Other MCI drivers can be distributed with the applications or hardware devices that use them.
Syntax of Command Strings
MCI command strings use a consistent verb-object-modifier syntax. Each command string includes a command, a device identifier, and command arguments. Arguments are optional on some commands and required on other commands.
A command string has the following form:
command device_id arguments
These components contain the following information:
The command specifes an MCI command. Examples of commands include:
open, close, and play.
The device_id specifies an instance of an MCI driver. The device_id is created when the device is opened.
See "Using the Open Command" for information on how the device ID is assigned.
The arguments specify the flags and parameters used by the command. Flags are key words recognized with the MCI command. Parameters are numbers or strings that apply to the MCI command or flag.
For example, the play command uses the arguments from position and to position to indicate the positions to start and end playing. You can list the flags used with a command in any order. When you use a flag that has a parameter associated with it, you must supply a value for the parameter.
Unspecified (and optional) command arguments assume a default value.
Data Types for Command Parameters
You can use the following data types for the parameters in a command string:
Data Type Description
String data types are delimited by leading and trailing white space and quotation marks ("). MCI removes single quotation marks from a string. To put a quotation mark in a string, use a set of two quotation marks where you want to embed your quotation mark. To use an empty string, use two quotation marks to delimit the empty string.
Signed long integers
Signed long integer data types are delimited by leading and trailing white space. Unless otherwise specified, integers can be positive or negative. If you use negative integers, don't put any space between the minus sign and the first digit.
Rectangles
Rectangle data types are an ordered list of four signed short values. White space delimits this data type as well as separates each integer in the list.
Using the Wait Flag
Normally, MCI commands return to the user immediately, even if it takes several minutes to complete the action initiated by the command. For example, after a VCR device receives a rewind command, the command returns when the tape starts to rewind. It does not wait for the tape to finish rewinding. You can use the wait flag to direct the device to wait until the requested action is completed before returning control to the application.
For example, the following play command won't return control to the application until the playback completes:
"play mydevice from 0 to 100 wait"
The user can cancel a wait operation by pressing a break key. By default, this key is CTRL+BREAK. When a wait operation is cancelled, MCI attempts to return control to the application without interrupting the command associated with the wait flag. For example, in the preceding example, breaking the play command cancels the wait operation without interrupting the play operation. To redefine the break key, use the break command.
Using the Notify Flag
The notify flag directs the device to post an MM_MCINOTIFY message when the device completes an action. Your application must have a window procedure to process the MM_MCINOTIFY message for notification to have any effect. The Multimedia Programmer's Guide includes examples of window procedures that process the MM_MCINOTIFY message.
A notification message can indicate one of the following results:
òThe notification is successful òThe notification is superseded òThe notification is aborted òThe notification fails
A successful notification occurs when the conditions required for initiating the callback are satisfied and the command completed without interruption.
A notification is superseded when the device has a notification pending and you send it another notify request. When a notification is superseded, MCI resets the callback conditions to correspond to the notify request of the new command.
A notification is aborted when you send a new command that prevents the callback conditions set by a previous command from being satisfied. For example, sending the stop command cancels a notification pending for the "play to 500 notify" command. If your command interrupts a command that has a notification pending, and your command also requests notification, MCI will abort the first notification immediately and respond to the second notification.
A notification fails if a device error occurs while a device is executing the MCI command. For example, a notification fails when a hardware error occurs during a play command.
Using All as the Device ID
You can specify all as a device ID for any command that does not return information. When you specify all, MCI sequentially sends the command to all devices opened by the current application.
For example, "close all" closes all open devices and "play all" starts playing all devices opened by the application. Because MCI sequentially sends the commands to the MCI devices, there is a delay between when the first device receives the command and when the last device receives the command.
Combining the Device Name and Element Name
You can eliminate the type flag in the open command if you combine the device name with the device element name. MCI recognizes this combination when you use the following syntax:
"device_name!element_name"
The exclamation point separates the device name from the element name. There should not be any spaces between the exclamation point and the device_name or element_name. The following example opens the RIGHT.WAV element using the "waveaudio" device:
"open waveaudio!right.wav"
Opening Devices Automatically
If MCI cannot identify the device_name of a command as an open device, MCI tries to automatically open the specified device. The following items apply to devices automatically opened:
Automatic open works only with the command-string interface.
Automatic open does not let your application specify the type flag. Without the device name, MCI determines the device name from the [mci extensions] section of the WIN.INI file. To use a specific device, you can combine the device name name with the device element name using the exclamation point. (See "Combining the Device Name and Element Name for information".)
Automatic open will fail for commands that are specific to custom device drivers. For example, the command used to unlock the front panel of the Pioneer videodisc player will fail an automatic open. The command used for unlocking the front panel is specific only to this videodisc player.
Automatically opened devices don't respond to commands that use all as a device name.
MCI automatically closes any device automatically opened using the command-string interface. MCI closes a device in the following situations:
òWhen the command is completed òWhen you abort the command òWhen you request notification in a subsequent command òWhen MCI detects a failure
Using the Open Command
Before using a device, you must initialize it by using the open command. The open command loads the driver into memory (if it isn't already loaded) and establishes the device ID that you will use to identify the device in subsequent MCI commands. The number of devices you can have open is limited only by the amount of available memory. The open command has the following form:
open device shareable type device_name alias alias
The parameters for the open command are as follows:
Parameters Description
---------- ----------------------------------
device Identifies the MCI driver or media
element to open.
shareable Allows applications to share a common
device or device element.
type device_name Identifies the MCI device name when
device refers to a media element instead of
a specific MCI device name.
alias alias Specifies replacement name alias for
the device.
When specifying a device name in the device or device_name parameters, you can specify a device name from the SYSTEM.INI file or the filename of the device driver. If you specify the filename of the device driver, you can optionally include the .DRV extension; don't include the path to the file.
Note: Opening a device using the device driver filename makes the application device dependent and can prevent the application from running if the system configuration changes.
For example, the following command opens the cdaudio device and assigns alias "mycd":
"open cdaudio alias mycd"
The next command opens waveform file C:\WINDOWS\CHIMES.WAV and assigns alias "chimes":
"open c:\windows\chimes.wav type waveaudio alias chimes"
How the Device ID Is Assigned
The device ID established by the open command identifies the open MCI device in all subsequent commands. If you specify a device alias using the alias keyword, the device ID will be the alias. Otherwise, the device ID will be the device name.
Playing a Device
The play command starts playing a device. Without any flags, the play command starts playing from the current position and plays until the command is halted or until the end of the media or file is reached. For example, the following command starts playing an audio disc from the position where it was stopped:
"play cdaudio"
Most devices that support the play command also support the from and to flags. These flags indicate the position at which the device should start and stop playing. For example, the following command plays an audio disc from the beginning of the first track:
"play cdaudio from 0"
Some device types extend the play command to use the capabilities of a particular device. For example, the play command for videodisc devices adds the fast, slow, and scan flags.
Specifying Time Formats
The units assigned to the position value depend on the time format used by the device. Each device has a default time format, but it's always good practice to specify the time format (using the set command) before issuing any commands that use position values.
Stopping and Pausing a Device
The stop command suspends the playing or recording of a device. Many devices also include the basic command pause. The difference between stop and pause depends on the device. Usually pause suspends operation but leaves the device ready to resume playing or recording immediately.
Using play or record to restart a device will reset the to and from positions specified before the device was paused or stopped. Without the from flag, these commands reset the start position to the current position. Without the to flag, they reset the end position to the end of the media.
To continue playing or recording while stopping at a previously specified position, use the to flag with the play or record commands to specify an ending position.
Some devices include the resume command to restart a paused device. This command does not change the to and from positions specified with the play or record command which preceded the pause command.
Getting Information from a Device
Every device responds to the capability, status, and info commands. These commands obtain information about the device. For example, the following command returns true if the cdaudio device can eject the disc:
"capability cdaudio can eject"
With the MCICDA.DRV driver included with the SDK, this example returns true.
The flags listed for the required and basic commands provide a minimum amount of information about a device. Many devices supplement the required and basic flags with extended flags to provide additional information about the device.
When you request information by using the capability, status, or info command, the argument list can contain only one flag requesting information. The command-string interface can only return one string or value in response to a command requesting information.
Closing a Device
The close command releases access to a device or device element. To help MCI manage the devices, your application must explicitly close each device or device element when it is finished with it.
Using All as the Device ID
You can specify all as a device ID for any command that does not return information. When you specify all, MCI sequentially sends the command to all devices opened by the current application.
For example, "close all" closes all open devices and "play all" starts playing all devices opened by the application. Because MCI sequentially sends the commands to the MCI devices, there is a delay between when the first device receives the command and when the last device receives the command.
Audio CD Commands
The following list summarizes the commands used with the "cdaudio" device type:
Command Description
------- -------------------------------------
capability Obtains the capabilities of a device.
close Closes the device.
info Obtains textual information from a device.
open Initializes the device.
pause Pauses playing.
play Starts playing the device.
resume Resumes playing or recording on a paused device.
seek Seeks forward or backward.
set Sets the operating state of the device.
status Obtains status information from the device.
stop Stops playing.
Animation Commands
The following list summarizes the MCI commands used with the "animation" device type:
Command Description
------- -------------------------------------
capability Obtains the capabilities of a device.
close Closes the device.
info Obtains textual information from a device.
open Initializes the device.
pause Pauses the device.
play Starts playing an animation sequence.
put Defines the source, destination, and frame windows.
realize Tells the device to select and realize its palette
into a display context of the displayed window.
resume Resumes playing or recording on a paused device.
seek Moves to the specified position on the animation
and stops.
set Establishes control settings for the driver.
status Obtains status information from the device.
step Step the play one or more frames forward or reverse.
stop Stops playing.
update Repaints the current frame into the display context.
where Obtains the rectangle specifying the source or
destination area.
window Tells the device to use a given window for display
instead of the default window.
MIDI Sequencer Commands
The following list summarizes the commands used with the "sequencer" device type:
Command Description
------- -------------------------------------
capability Obtains the capabilities of a device.
close Closes the device.
info Obtains textual information from a device.
open Initializes the device.
pause Pauses playing or recording.
play Starts transmitting output data.
record Starts recording input data.
resume Resumes playing or recording on a paused device.
save Saves data to a disk file.
seek Seeks forward or backward.
set Sets the operating state of the device.
status Obtains status information from the device.
stop Stops playing or recording.
Videodisc Command Overview
The following list summarizes the commands used with the "videodisc" device type:
Command Description
------- -------------------------------------
capability Obtains the capabilities of a device.
close Closes the device.
escape Sends custom information to a device.
info Obtains textual information from a device.
open Initializes the device.
pause Pauses playing.
play Starts playing the device.
resume Resumes playing or recording on a paused device.
seek Seeks forward or backward.
set Sets the operating state of the device.
spin Starts the disc spinning or stops the disc from spinning.
status Obtains status information from the device.
step Step the play one or more frames forward or reverse.
stop Stops playing.
Video Overlay Command Overview
The following list summarizes the commands used with the "overlay" device type:
Command Description
------- ------------------------------------
capability Obtains the capabilities of a device.
close Closes the device.
freeze Disables video acquisition to the frame buffer.
info Obtains textual information from a device.
load Recalls data from a disk file.
open Initializes the device.
put Defines the source, destination, and frame windows.
save Saves data to a disk file.
set Sets the operating state of the device.
status Obtains status information from the device.
unfreeze Enables the frame buffer to acquire video data.
where Obtains the rectangle specifying the source,
destination, or frame area.
window Tells the device to use a given window for
display instead of the default window.
Waveform Audio Command Overview
The following list summarizes the commands used with the "waveaudio" device type:
Command Description
------- -------------------------------------
capability Obtains the capabilities of a device.
close Closes the device.
cue Prepares for playing or recording.
delete Deletes a data segment from the MCI element.
info Obtains textual information from a device.
open Initializes the device.
pause Pauses playing or recording.
play Starts transmitting output data.
record Starts recording input data.
resume Resumes playing or recording on a paused device.
save Saves data to a disk file.
seek Seeks forward or backward.
set Sets the operating state of the device.
status Obtains status information from the device.
stop Stops playing or recording.
Keywords: Last Updated: 1996 Author: Peter Caban Area: Gen TechNotes